<?php if(!defined('ROOTPATH')) die('Not defined ROOTPATH');
//自动转换Unix/Windows文件路径符号
define('DS', DIRECTORY_SEPARATOR);

//定义主路径
define('SYSPATH', ROOTPATH. 'system'. DS);
define('SITEPATH', ROOTPATH. 'sites'. DS. getTopLevelDomain(). DS);

global $_CFG;
global $_LOAD;

//包含主文件
require(SYSPATH. 'cfg'. DS. 'common.php');
require(SYSPATH. 'woosize.php');

function getTopLevelDomain($domain=NULL)
{
    $domain = ($domain===NULL) ? $_SERVER['HTTP_HOST'] : $domain;
    if(preg_match('/(\w+[\-\w+]*)\.([a-z]{2,3}\.[a-z]{2}|[a-z]{2,4})$/i', $domain, $m)){
        return $m[0];
    }
    return FALSE;
}

function getClientIP()
{
    return empty($_SERVER['REMOTE_ADDR']) ? 'unknown' : $_SERVER['REMOTE_ADDR'];
}

function getServerIP()
{
    return empty($_SERVER['SERVER_ADDR']) ? 'unknown' : $_SERVER['SERVER_ADDR'];
}

